import { followAPI } from "@/api/homeApi.ts";
import { showFailToast } from "vant";
import type { FollowType } from "@/types/homeTypes";
import { ref } from "vue";

const useFollow = () => {

    const loading = ref<boolean>(false);

    const follow = async (type: FollowType, id: string): Promise<void> => {
        try {
            loading.value = true;
            await followAPI(type, id);
        } catch (error: any) {
            showFailToast(error.meta);
        } finally {
            loading.value = false;
        }
    };

    return {
        loading,
        follow,
    };

};

export default useFollow;
